impute<-read.table("impute_chr20_util_gen_r2",sep="\t")
dim(impute)
colnames(impute)<-colnames(data)<-c("marker_identifier","minor_allele","minor_allele_frequency","allelic_r_squared","dosage_r_squared","HWE_dosage_r_squared","accuracy","missing_score")
colnames(impute)<-c("marker_identifier","minor_allele","minor_allele_frequency","allelic_r_squared","dosage_r_squared","HWE_dosage_r_squared","accuracy","missing_score")
beagle<-read.table("beagle_chr20_util_gen_r2",sep="\t")
colnames(beagle)<-c("marker_identifier","minor_allele","minor_allele_frequency","allelic_r_squared","dosage_r_squared","HWE_dosage_r_squared","accuracy","missing_score")
dim(beagle)
dim(impute)
merged<-merge(beagle,impute,by="marker_identifier")
dim(merged)
merged[1,]
getwd()
pos<-read.table("chr20.one.phased.impute2_fil_chr20_info",sep=" ",head=T)
dim(pos)
pos[1,]
pos<-pos[,c(2,3)]
dim(pos)
pos[1,]
colnames(pos)<-c("marker_identifier","position)
colnames(pos)<-c("marker_identifier","position")
merged<-merge(merged,pos,by="marker_identifier")
dim(merged)
merged[1,]
pdf("beagle_dosR2VSimpute_dosR2.pdf")
plot(merged$position,merged$dosage_r_squared.x,ylim=c(0,1),xlab = c("POSITION"),ylab = c("R2 value"),main=c("beagle r2 vs impute r2")
)
dev.off()
pdf("beagle_dosR2VSimpute_dosR2.pdf")
plot(merged$position,merged$dosage_r_squared.x,ylim=c(0,1),xlab = c("POSITION"),ylab = c("R2 value"),main=c("beagle r2 (red) vs impute r2 (green)")
,pch="*",col=c("red"))
points(merged$position,merged$dosage_r_squared.y,pch="*",col=c("green"))
dev.off()
dev.off()
 pdf("beagle_dosR2VSimpute_dosR2.pdf")
plot(merged$position,merged$dosage_r_squared.x,ylim=c(0,1),xlab = c("POSITION"),ylab = c("R2 value"),main=c("beagle r2 (red) vs impute r2 (green)") ,pch=".",col=c("red"))
dev.off()
pdf("beagle_dosR2VSimpute_dosR2.pdf")
plot(merged$position,merged$dosage_r_squared.x,ylim=c(0,1),xlab = c("POSITION"),ylab = c("R2 value"),main=c("beagle dosage r2 (red) vs impute dosage r2 (green)") ,pch=".",col=c("red"))
points(merged$position,merged$dosage_r_squared.y,pch=".",col=c("green"))
dev.off()
which(merged$dosage_r_squared.x >0.3 & merged$dosage_r_squared.y>0.3)[1]
length(which(merged$dosage_r_squared.x >0.3 & merged$dosage_r_squared.y>0.3))
merged_dosr2_gt_0p3<-merged[which(merged$dosage_r_squared.x >0.3 & merged$dosage_r_squared.y>0.3),]
dim(merged_dosr2_gt_0p3)
pdf("snps_dosr2_gt_0p3_beagle_vs_impute.pdf")
plot(merged$dosage_r_squared.x,merged$dosage_r_squared.y,xlab = c("beagle dosage r2"),ylab=c("impute dosage r2"))
cor(merged$dosage_r_squared.x,merged$dosage_r_squared.y,method="pearson")
main<-paste("Beagle dos r2 VS Impute dos r2 for snps both dos r2 > 0.3 ,pearson corr=",cor(merged$dosage_r_squared.x,merged$dosage_r_squared.y,method="pearson"),sep=" ")
main
dev.off()
 pdf("snps_dosr2_gt_0p3_beagle_vs_impute.pdf")
plot(merged$dosage_r_squared.x,merged$dosage_r_squared.y,xlab = c("beagle dosage r2"),ylab=c("impute dosage r2"),main=main)
dev.off()
main<-paste("Beagle_Dos_r2 VS Impute_Dos_r2[Snps with both dosr2>0.3],PearsonCorr=",cor(merged$dosage_r_squared.x,merged$dosage_r_squared.y,method="pearson"),sep=" ")
pdf("snps_dosr2_gt_0p3_beagle_vs_impute.pdf")
plot(merged$dosage_r_squared.x,merged$dosage_r_squared.y,xlab = c("beagle dosage r2"),ylab=c("impute dosage r2"),main=main)
dev.off()
 pdf("snps_dosr2_gt_0p3_beagle_vs_impute.pdf",width =10,height=8)
plot(merged$dosage_r_squared.x,merged$dosage_r_squared.y,xlab = c("beagle dosage r2"),ylab=c("impute dosage r2"),main=main,pch=".")
dev.off()
savehistory("plot.R")
